<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/core" prefix="c"%>
<script type="text/javascript" src="js/calendar/PopupWindow.js"></script>
<script type="text/javascript" src="js/calendar/CalendarPopup.js"></script>
<script type="text/javascript" src="js/calendar/AnchorPosition.js"></script>
<script type="text/javascript" src="js/calendar/date.js"></script>
<script type="text/javascript">
	var bushelUnit = <bean:write name="BUSHEL_UNIT"/>;
	var conUnit = <bean:write name="CON_UNIT"/>;
	function submitPlantQuery(form, orderField, orderType){
		form.orderField.value = orderField;
		form.orderType.value = orderType;
		form.action = "assignPurchaseOfFutures.do";
		if (validSubmit){
			form.submit();
		} else {
			alert('<fmt:message key="warning.message.common.processing"/>');
		}
	}
	function changeTotal(forma,changeElement){
		var arrQuantities = forma.quantities;
		var arrAvailables = forma.availables;
		var totalAssign = forma.totalAssign;
		
		var total = 0;
		if( arrQuantities != undefined ){
			if( arrQuantities.length == undefined ){
				if( parseFloat( arrQuantities.value ) > parseFloat( arrAvailables.value ) ){
					alert('Error: \n<bean:message key="error.message.purchaseorder.purchaseoffuture.availables"/>');
					changeElement.focus();
				}else{
					if( trim( arrQuantities.value ) != "" ){
						total = parseFloat( arrQuantities.value );
					}
				}
			}else{
				for( var int_i = 0; int_i < arrQuantities.length; int_i++ ){
					if( changeElement == arrQuantities[int_i] ){
						if( parseFloat( changeElement.value ) > parseFloat( arrAvailables[int_i].value ) ){
							alert('Error: \n<bean:message key="error.message.purchaseorder.purchaseoffuture.availables"/>');
							changeElement.focus();
							break;
						}
					}
					if( trim(arrQuantities[int_i].value) != "" ){
						total += parseFloat( arrQuantities[int_i].value );
					}
				}
			}
			if( int_i == arrQuantities.length ){
				totalAssign.value = total;
			}
		}
		changeAssContracts();
	}

	function validateSubmit(forma){
		var arrQuantitiesSpot = forma.quantitiesSpot;
		var arrUnitPrices = forma.unitPrices;
		var arrPurchasesDate = forma.purchasesDate;
		var retVal = true;
		for( var int_i = 0; int_i < arrQuantitiesSpot.length; int_i++ ){
			errors = "";
			if( trim( arrQuantitiesSpot[int_i].value ) != "" || trim( arrUnitPrices[int_i].value ) != "" || trim( arrPurchasesDate[int_i].value ) != "" ){
				if( trim( arrPurchasesDate[int_i].value ) == "" ){
					errors = '<bean:message key="error.message.purchaseorder.purchaseoffuture.purchasedate.required"/>\n';
				}else{
					if( !isValidDate( trim( arrPurchasesDate[int_i].value ) ) ){
						errors = '<bean:message key="error.message.purchaseorder.purchaseoffuture.purchasedate.invalid"/>\n';
					}
				}
				if( trim( arrQuantitiesSpot[int_i].value ) == "" ){
					errors += '<bean:message key="error.message.purchaseorder.purchaseoffuture.contracts.required"/>\n';
				}
				if( trim( arrUnitPrices[int_i].value ) == "" ){
					errors += '<bean:message key="error.message.purchaseorder.purchaseoffuture.unitPrice.required"/>\n';
				}
				if( errors != "" ){
					alert('Spot '+(int_i+1)+': \n'+errors);
					retVal = false;
					break;
				}
			}
		}
		return retVal;
	}
	
	function changeTotalSpot(forma,changeElement){
		var arrQuantitiesSpot = forma.quantitiesSpot;
		var arrBushelsSpot = forma.bushelsSpot;
		var arrUnitPrices = forma.unitPrices;
		var arrTotalPricesSpot = forma.totalPricesSpot;
		var assComSpot = forma.assComSpot;
		var total = 0;
		if( arrQuantitiesSpot != undefined ){
			if( arrQuantitiesSpot.length == undefined ){
				total = parseFloat( arrQuantitiesSpot.value );
			}else{
				for( var int_i = 0; int_i < arrQuantitiesSpot.length; int_i++ ){
					if( trim(arrQuantitiesSpot[int_i].value) != "" ){
						total += parseFloat( arrQuantitiesSpot[int_i].value );
						arrBushelsSpot[int_i].value = addCommas( decimales( (parseFloat( arrQuantitiesSpot[int_i].value ) / conUnit)* bushelUnit, 4) );
						if( arrUnitPrices[int_i].value != "" ){
							arrTotalPricesSpot[int_i].value = "$"+addCommas( decimales( parseFloat( arrUnitPrices[int_i].value ) * parseFloat( arrBushelsSpot[int_i].value.replace(/,/g, "") ), 4 ) );
						}else{
							arrTotalPricesSpot[int_i].value = "$";
						}
					}else{
						arrBushelsSpot[int_i].value = "";
						arrTotalPricesSpot[int_i].value = "$";
					}
				}
			}
		}
		assComSpot.value = total;
		changeAssContracts();
	}

	function changeUnitPriceSpot(forma,changeElement){
		var arrQuantitiesSpot = forma.quantitiesSpot;
		var arrBushelsSpot = forma.bushelsSpot;
		var arrUnitPrices = forma.unitPrices;
		var arrTotalPricesSpot = forma.totalPricesSpot;
		
		if( arrUnitPrices != undefined ){
			for( var int_i = 0; int_i < arrUnitPrices.length; int_i++ ){
				if( arrUnitPrices[int_i] == changeElement ){
					if( trim(arrUnitPrices[int_i].value) != "" ){
						if( arrQuantitiesSpot[int_i].value != "" ){
							arrTotalPricesSpot[int_i].value = "$"+addCommas( decimales( parseFloat( arrUnitPrices[int_i].value ) * parseFloat( arrBushelsSpot[int_i].value.replace(/,/g, "") ), 4 ) );
						}
					}else{
						arrTotalPricesSpot[int_i].value = "$";
					}
				}
			}
		}
	}
	
	function changeAssContracts(){
		var assContracts;
		var totalAssign;
		totalAssign = document.getElementById("totalAssign");
		assContracts = document.getElementById("assignedContracts");
		assComSpot = document.getElementById("assComSpot");
		if( totalAssign.value == "" ){
			totalAssign.value = "0";
		}
		if( assComSpot.value == "" ){
			assComSpot.value = "0"; 
		}
		assContracts.value = parseFloat( totalAssign.value ) + parseFloat( assComSpot.value );
	}
</script>
<logic:present name="purchaseOrderSpotViews">
	<logic:iterate name="purchaseOrderSpotViews" id="spot" indexId="rowNumber">
		<DIV ID="div_purchaseDate<%= rowNumber.intValue() %>" STYLE="position:absolute;visibility:hidden;background-color:white"></DIV>
		<script>
			var calendarJS<%= rowNumber.intValue() %> = new CalendarPopup("div_purchaseDate<%= rowNumber.intValue() %>");
			calendarJS<%= rowNumber.intValue() %>.showNavigationDropdowns();
			calendarJS<%= rowNumber.intValue() %>.setCssPrefix("TEST");
			calendarJS<%= rowNumber.intValue() %>.setYearSelectStartOffset(80);
		</script>
	</logic:iterate>
</logic:present>
<html:form action="/assignPurchaseOfFuturesSave">
	<html:hidden property="purchaseOrderAssignFuturesView.purchaseOrderId"/>
	<html:hidden property="orderField"/>
	<html:hidden property="orderType"/>
	<table width="600" align="center" border="0">
		<tr>
			<td>
				<table width="100%" align="center" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
					<tr>
						<td align="center" class="titulocolumna"><bean:message key="label.purchaseorder.purchaseoffuture.assignation.title"/></td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table width="100%" align="center" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
					<tr>
						<td class="etiqueta" width="9%"><bean:message key="label.transports.query.code"/>:</td>
						<td class="etiqueta_campo_center" width="10%">
							<bean:write name="purchaseOrderView" property="purchaseOrderCode"/><bean:write name="purchaseOrderView" property="postFix"/>
						</td>
						<td class="etiqueta" width="12%"><bean:message key="label.transports.query.transport"/>:</td>
						<td class="etiqueta_campo_center" width="19%">
							<bean:write name="transportView" property="transportDescription"/>
						</td>
						<td class="etiqueta" width="10%"><bean:message key="label.purchaseorder.purchaseoffuture.assignation.capacity"/>:</td>
						<td class="etiqueta_campo_center" width="15%">
							<bean:write name="purchaseOrderView" property="purchaseOrderCapacity" format="###,###,##0.000"/>
						</td>
						<td class="etiqueta" width="10%"><bean:message key="label.purchaseorder.purchaseoffuture.assignation.realcapacity"/>:</td>
						<td class="etiqueta_campo_right" width="15%">
							<bean:write name="purchaseOrderView" property="purchaseOrderRealCapacity" format="###,###,##0.000"/>
						</td>
					</tr>
					<tr>
						<td colspan="7" align="right" class="etiqueta"><bean:message key="label.purchaseorder.purchaseoffuture.assignation.contract"/>:</td>
						<td class="etiqueta_campo_right"><bean:write name="purchaseOrderView" property="purchaseOrderCapacityConverted" format="###,###,##0"/></td>
					</tr>
					<tr>
						<td colspan="7" align="right" class="etiqueta"><bean:message key="label.purchaseorder.purchaseoffuture.assignation.assigned"/>:</td>
						<td class="etiqueta_campo_right"><input type="text" disabled="disabled" readonly="true" id="assignedContracts" class="columnanumero"></td>
					</tr>
					<tr>					
						<td colspan="3" align="right" class="etiqueta"><bean:message key="label.purchaseorder.purchaseoffuture.assignation.bushelprice"/>:</td>
						<td class="etiqueta_campo_right"><input size="8" value="<bean:write name="purchaseOrderView" property="bushelPrice"  format="###,###,##0.0000"/>" type="text" name="purchaseOrderAssignFuturesView.bushelPrice" id="bushel" class="columnanumero" onfocus="this.select();" onkeydown="return (numeric(event, 1) && noPaste(event, this));" onkeyup="extractNumber(this,4,false);"/></td>
						<td class="etiqueta" colspan="1">&nbsp;</td>
						<td align="right" class="etiqueta"><bean:message key="label.purchaseorder.purchaseoffuture.assignation.comission"/>:</td>
						<td colspan="2" class="etiqueta_campo_right"><input value="<bean:write name="PurchaseOrderAssignFutureForm" property="purchaseOrderAssignFuturesView.commission"  format="###,###,##0.0000"/>" type="text" name="purchaseOrderAssignFuturesView.commission" id="commission" class="columnanumero" onfocus="this.select();" onkeydown="return (numeric(event, 1) && noPaste(event, this));" onkeyup="extractNumber(this,4,false);"/></td>
						
					</tr>
					<tr>
						<td colspan="8"  class="columnadatopar" align="center">&nbsp;</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table width="100%" align="center" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
					<tr>
						<td align="center" class="titulocolumna"><bean:message key="label.purchaseorder.purchaseoffuture.spotpurchase.title"/></td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table width="100%" align="center" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
					<tr>
						<td class="etiqueta_campo_center">
							<bean:message key="label.purchaseorder.purchaseoffuture.spotpurchase.purchasedate"/>
						</td>
						<td class="etiqueta_campo_center">
							<bean:message key="label.purchaseorder.purchaseoffuture.spotpurchase.contracts"/>						
						</td>
						<td class="etiqueta_campo_center">
							<bean:message key="label.purchaseorder.purchaseoffuture.spotpurchase.bushels"/>
						</td>
						<td class="etiqueta_campo_center">
							<bean:message key="label.purchaseorder.purchaseoffuture.spotpurchase.unitprice"/>						
						</td>
						<td class="etiqueta_campo_center">
							<bean:message key="label.purchaseorder.purchaseoffuture.spotpurchase.price"/>						
						</td>						
					</tr>
					<logic:present name="purchaseOrderSpotViews">
						<logic:iterate name="purchaseOrderSpotViews" id="spot" indexId="rowNumber">
							<bean:define id="purchaseOrderSpotIdValue"><bean:write name="spot" property="purchaseOrderSpotId"/></bean:define>
							<html:hidden styleId="purchaseOrderSpotsId" name="purchaseOrderAssignFuturesView.purchaseOrderSpotViews" value="<%=purchaseOrderSpotIdValue%>" property="purchaseOrderSpotId" indexed="true"/>
							
							<bean:define id="bushelUnitValue"><bean:write name="spot" property="bushelUnit"/></bean:define>
							<html:hidden styleId="bushelUnits" name="purchaseOrderAssignFuturesView.purchaseOrderSpotViews" value="<%=bushelUnitValue%>" property="bushelUnit" indexed="true"/>
							<tr class="columnadato<%= rowNumber.intValue()%2 == 0 ? "Non" : "Par" %>">
								<td>
									<logic:notPresent name="spot" property="purchaseDate">
										<html:text styleId="purchasesDate" name="purchaseOrderAssignFuturesView.purchaseOrderSpotViews" value="" property="purchaseDate" size="10" styleClass="columnaCaptura" indexed="true" />
									</logic:notPresent>
									<logic:present name="spot" property="purchaseDate">
										<bean:define id="purchaseDateValue"><bean:write name="spot" property="purchaseDate"/></bean:define>
										<html:text styleId="purchasesDate" name="purchaseOrderAssignFuturesView.purchaseOrderSpotViews" value="<%=purchaseDateValue%>" property="purchaseDate" size="10" styleClass="columnaCaptura" indexed="true" />
									</logic:present>
									&nbsp;
									<a href="#>" onclick="calendarJS<%=rowNumber.intValue()%>.select(document.forms[0].purchasesDate[<%=rowNumber.intValue()%>],'a_purchaseDate<%= rowNumber.intValue() %>','dd/MM/yyyy');" class="pointerhand" NAME="an_purchaseDate<%= rowNumber.intValue() %>" ID="a_purchaseDate<%= rowNumber.intValue() %>"><img id="img_purchaseDate<%= rowNumber.intValue() %>" src="images/calendar.gif" border="0" /></a>
								</td>							
								<td>
									<logic:notPresent name="spot" property="quantity">
										<html:text styleId="quantitiesSpot" name="purchaseOrderAssignFuturesView.purchaseOrderSpotViews" value="" property="quantity" size="10" styleClass="columnanumero" indexed="true" onblur="changeTotalSpot(this.form,this);" onfocus="this.select();" onkeydown="return (numeric(event, 0) && noPaste(event, this));" onkeyup="extractNumber(this,0,false);"/>
									</logic:notPresent>
									<logic:present name="spot" property="quantity">
										<bean:define id="quantitySpotValue"><bean:write name="spot" property="quantity"/></bean:define>
										<html:text styleId="quantitiesSpot" name="purchaseOrderAssignFuturesView.purchaseOrderSpotViews" value="<%=quantitySpotValue%>" property="quantity" size="10" styleClass="columnanumero" indexed="true" onblur="changeTotalSpot(this.form,this);" onfocus="this.select();" onkeydown="return (numeric(event, 0) && noPaste(event, this));" onkeyup="extractNumber(this,0,false);"/>
									</logic:present>
								</td>
								<td align="right">
									<input class="columnanumero" id="bushelsSpot" size="16" disabled="disabled" value="<bean:write name="spot" property="bushels"/>"/>
								</td>
								<td>
									<logic:notPresent name="spot" property="unitPrice">
										<html:text styleId="unitPrices" name="purchaseOrderAssignFuturesView.purchaseOrderSpotViews" value="" property="unitPrice" size="10" styleClass="columnanumero" indexed="true" onblur="changeUnitPriceSpot(this.form,this);" onfocus="this.select();" onkeydown="return (numeric(event, 1) && noPaste(event, this));" onkeyup="extractNumber(this,4,false);"/>
									</logic:notPresent>
									<logic:present name="spot" property="unitPrice">
										<bean:define id="unitPriceValue"><bean:write name="spot" property="unitPrice"/></bean:define>
										<html:text styleId="unitPrices" name="purchaseOrderAssignFuturesView.purchaseOrderSpotViews" value="<%=unitPriceValue%>" property="unitPrice" size="10" styleClass="columnanumero" indexed="true" onblur="changeUnitPriceSpot(this.form,this);" onfocus="this.select();" onkeydown="return (numeric(event, 1) && noPaste(event, this));" onkeyup="extractNumber(this,4,false);"/>
									</logic:present>
								</td>
								<td align="right">
									<input class="columnanumero" id="totalPricesSpot"  size="16" disabled="disabled" value="$<bean:write name="spot" property="totalPrice"/>"/>
								</td>
							</tr>
						</logic:iterate>
					</logic:present>
					<tr>
						<td colspan="5" class="etiqueta">
							<bean:message key="label.purchaseorder.purchaseoffuture.spotpurchase.spotpurchasesassignedtotal"/>&nbsp;<input type="text" id="assComSpot" name="assComSpot" class="columnanumero" readonly="true" disabled="disabled"/>				
						</td>
					</tr>
					<tr>
						<td colspan="8"  class="columnadatopar" align="center">&nbsp;</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table width="100%" align="center" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
					<tr>
						<td class="titulo_lista_interna" align="center" width="16%">							
							<a href="#>" onclick="return submitPlantQuery(document.PurchaseOrderAssignFutureForm, 1,'<c:choose><c:when test="${previousOrderField == 1 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
									<bean:message key="message.futurepurchase.periodaccount"/>
								<c:choose>
									<c:when test="${previousOrderField == 1 && previousOrderType == 1}">
										<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
									</c:when>
									<c:when test="${previousOrderField == 1 && previousOrderType == 0}">
										<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
									</c:when>
								</c:choose>
							</a>		
						</td>
						<td class="titulo_lista_interna" align="center" width="16%">							
							<a href="#>" onclick="return submitPlantQuery(document.PurchaseOrderAssignFutureForm, 0, '<c:choose><c:when test="${previousOrderField == 0 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
								<bean:message key="message.futurepurchase.periodapplication"/>
								<c:choose>
								<c:when test="${previousOrderField == 0 && previousOrderType == 1}">
									<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
								</c:when>
								<c:when test="${previousOrderField == 0 && previousOrderType == 0}">
									<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
								</c:when>
								</c:choose>
							</a>
						</td>
						<td class="titulo_lista_interna" align="center" width="16%">							
							<a href="#>" onclick="return submitPlantQuery(document.PurchaseOrderAssignFutureForm, 2, '<c:choose><c:when test="${previousOrderField == 2 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
								<bean:message key="message.futurepurchase.reference"/>
								<c:choose>
									<c:when test="${previousOrderField == 2 && previousOrderType == 1}">
										<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
									</c:when>
									<c:when test="${previousOrderField == 2 && previousOrderType == 0}">
										<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
									</c:when>
								</c:choose>
							</a>
						</td>
						<td class="titulo_lista_interna" align="center" width="16%">							
							<a href="#>" onclick="return submitPlantQuery(document.PurchaseOrderAssignFutureForm, 3, '<c:choose><c:when test="${previousOrderField == 3 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
								<bean:message key="message.futurepurchase.contracts"/>
								<c:choose>
									<c:when test="${previousOrderField == 3 && previousOrderType == 1}">
										<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
									</c:when>
									<c:when test="${previousOrderField == 3 && previousOrderType == 0}">
										<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
									</c:when>
								</c:choose>
							</a>
						</td>
						<td class="titulo_lista_interna" align="center" width="16%">							
							<a href="#>" onclick="return submitPlantQuery(document.PurchaseOrderAssignFutureForm, 4, '<c:choose><c:when test="${previousOrderField == 4 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
								<bean:message key="label.purchaseorder.purchaseoffuture.assignation.availables"/>
								<c:choose>
									<c:when test="${previousOrderField == 4 && previousOrderType == 1}">
										<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
									</c:when>
									<c:when test="${previousOrderField == 4 && previousOrderType == 0}">
										<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
									</c:when>
								</c:choose>
							</a>
						</td>
						<td class="titulo_lista_interna" align="center" width="20%">							
							<a href="#>" onclick="return submitPlantQuery(document.PurchaseOrderAssignFutureForm, 5, '<c:choose><c:when test="${previousOrderField == 5 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
								<bean:message key="label.futurepurchase.query.unitPrice"/>
								<c:choose>
									<c:when test="${previousOrderField == 5 && previousOrderType == 1}">
										<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
									</c:when>
									<c:when test="${previousOrderField == 5 && previousOrderType == 0}">
										<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
									</c:when>
								</c:choose>
								<c:if test="${previousOrderField == 0}">
									<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
								</c:if>
							</a>	
						</td>
						<td class="titulo_lista_interna" align="center" width="20%">														
							<bean:message key="label.purchaseorder.purchaseoffuture.assignation.assign"/>							
						</td>			
					</tr>
					<logic:iterate name="PurchaseOrderAssignFutureForm" property="purchaseOrderAssignFuturesView.purchaseOrderAssignFutureViews" id="futures" indexId="rowNumber">
						<tr class="columnadato<%= rowNumber.intValue()%2 == 0 ? "Non" : "Par" %>">
							<td><bean:write name="futures" property="accountFuturePeriodName"/></td>
							<td><bean:write name="futures" property="applicationFuturePeriodName"/></td>
							<td><bean:write name="futures" property="reference"/></td>
							<td><bean:write name="futures" property="totalQuantity" format="###,###,##0"/></td>
							<td><bean:write name="futures" property="availables" format="###,###,##0"/></td>
							<td><bean:write name="futures" property="unitPrice" /></td>
							<td>
								<logic:equal name="futures" property="assigned" value="true">
									<bean:define id="quantityValue"><bean:write name="futures" property="quantity"/></bean:define>
									<html:text styleId="quantities" name="purchaseOrderAssignFuturesView.purchaseOrderAssignFutureViews" value="<%=quantityValue%>" property="quantity" size="10" styleClass="columnanumero" indexed="true" onblur="changeTotal(this.form,this,5);" onfocus="this.select();" onkeydown="return (numeric(event, 0) && noPaste(event, this));" onkeyup="extractNumber(this,2,false);"/>
								</logic:equal>
								<logic:notEqual name="futures" property="assigned" value="true">
									<html:text styleId="quantities" name="purchaseOrderAssignFuturesView.purchaseOrderAssignFutureViews" value="" property="quantity" size="10" styleClass="columnanumero" indexed="true" onblur="changeTotal(this.form,this,5);" onfocus="this.select();" onkeydown="return (numeric(event, 0) && noPaste(event, this));" onkeyup="extractNumber(this,2,false);"/>
								</logic:notEqual>
								<bean:define id="cornFutureIdValue"><bean:write name="futures" property="cornFutureId"/></bean:define>
								<bean:define id="availablesValue"><bean:write name="futures" property="availables"/></bean:define>
								<html:hidden styleId="cornFutureIds" name="purchaseOrderAssignFuturesView.purchaseOrderAssignFutureViews" value="<%=cornFutureIdValue%>" property="cornFutureId"  indexed="true"/>
								<html:hidden styleId="availables" name="purchaseOrderAssignFuturesView.purchaseOrderAssignFutureViews" value="<%=availablesValue%>"  property="availables"  indexed="true"/>
							</td>							
						</tr>
					</logic:iterate>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table width="100%" align="center" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
					<tr>
						<td align="right" class="etiqueta" width="90%"><bean:message key="label.purchaseorder.purchaseoffuture.assignation.assigned"/>:</td>
						<td class="etiqueta_campo_center" width="10%"><input disabled="disabled" size="10" type="text" name="totalAssign" id="totalAssign" class="columnanumero"/></td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td align="right">
				<table align="center" width="100%" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
					<tr>
						<td style="text-align: center; vertical-align: bottom;" class="columnadatopar">
							<html:submit styleClass="boton" onclick="return validateSubmit(this.form);"><bean:message key="label.common.save"/></html:submit>
							<html:button property="cancel" onclick="location.href = 'listPurchaseProgramQuery.do?filters=news'" styleClass="boton"><bean:message key="label.common.cancel"/></html:button>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</html:form>
<script>
changeTotal(document.PurchaseOrderAssignFutureForm);
changeTotalSpot(document.PurchaseOrderAssignFutureForm);
</script>